<h2>DESCRIPTION</h2>

<i>r.resamp.rst</i> reinterpolates the values a from given raster map (named
<i>input</i>) to a new raster map (named <i>elev</i>). 
This module is intended for reinterpolation of continuous data
to a different resolution rather than for interpolation from scattered data
(use the <em>v.surf.*</em> modules for that purpose).

<p>
The extent of all resulting raster maps is taken from the settings of the
actual computational region (which may differ from the extent of the input
raster map). The resolution of the computational region however has to be
aligned to the resolution of the input map to avoid artefacts.

<p>
Reinterpolation (resampling) is done to higher, same or lower resolution 
specified by the <i>ew_res</i> and <i>ns_res</i> parameters.
<p>All resulting raster maps are created using the settings of the current
region (which may be different from that of the <i>input</i> raster map).
<p>Optionally, and simultaneously with interpolation, topographic parameters
are computed from an input raster map containing z-values of elevation/depth: slope, 
aspect, profile curvature (measured in the direction of steepest
slope), tangential curvature (measured in the direction of a tangent to
contour line) and/or mean curvature are computed from and saved as raster maps
as specified by the options <i>slope, aspect, pcurv, tcurv, mcurv</i> respectively.
<p>If the <i>-d</i> flag is set the program outputs partial derivatives fx, fy, 
fxx, fxy, and fyy instead of slope, aspect and curvatures.
<p>For noisy data it is possible to define spatially variable smoothing
by providing a raster map named by the <i>smooth</i> option containing 
smoothing parameters.

With the smoothing parameter set to zero (<i>smooth</i> is not given or
contains zero data), the resulting surface passes exactly through the data
points.
<p>The user can also define a raster map (named with <i>maskmap</i>) which will
be used as a mask. The interpolation is skipped for cells which have zero
or NULL value in the mask.
<p>Zero values will be assigned to these cells in all output raster maps.
<!-- is this still true???? -->
<p>The <i>zmult</i> parameter allows the user to rescale the z-values which may 
be useful, e.g., for transformation of elevations given in feet to meters,
so that the proper values of slopes and curvatures can be computed.
The default value is 1.
<p>A regularized spline with tension method is used for the interpolation.
The <i>tension</i> parameter tunes the character of the resulting surface 
from thin plate to membrane. Higher values of tension parameter reduce the 
overshoots that can appear in surfaces with rapid change of gradient. 
<p>The <i>-t</i> flag can be set to use "dnorm independent tension".
<!-- but what is "dnorm independent tension" ??? -->
<p>The interpolation is performed for overlapping rectangular segments. 
The user can define the width of overlap (in number of cells) with
the <i>overlap</i> option. The default value is 3.
<br>


<h2>NOTES</h2>

<i>r.resamp.rst</i> uses regularized spline with tension for interpolation
(as described in Mitasova and Mitas, 1993). 
<p>The region is temporarily changed while writing output files with desired 
resolution. Topographic parameters are computed in the same way as in 
the <i>v.surf.rst</i> module. (See also Mitasova and Hofierka, 1993)
<p>The raster map used with the <i>smooth</i> option should contain variable 
smoothing parameters. These can be derived from errors, slope, etc. using
the <i>r.mapcalc</i> module.
<p>The program gives warning when significant overshoots appear and higher
tension should be used. However, with tension set too high the resulting surface
changes its behavior to a membrane (rubber sheet stretched over the data
points resulting in a peak or pit in each given point and everywhere else
the surface goes rapidly to trend). Smoothing can be used to reduce
the overshoots. When overshoots occur the resulting <i>elev</i> file will
have white color in the locations of overshoots since the color table for
the output file is the same as colortable for raster input file.
<p>The program checks the numerical stability of the algorithm by computation 
of values at given points, and prints the maximum difference found into the 
history file of raster map <i>elev</i> (view with <i>r.info</i>). 
An increase in tension is suggested if the difference is unacceptable.
For computations with smoothing set to 0 this difference should be 0.
With a smoothing parameter greater than zero the surface will not pass through 
the data points exactly, and the higher the parameter the closer the surface 
will be to the trend.

<p>The program writes the values of parameters used in computation into
the comment part of the <i>elev</i> map history file. Additionally the 
following values are also written to assist in the evaluation of results 
and choosing of suitable parameters:
<ul>
<li>minimum and maximum z values in the data file (zmin_data, zmax_data) and
in the interpolated raster map (zmin_int, zmax_int),</li>
<li>maximum difference between the given and interpolated z value at a given 
point (errtotal),</li>
<li>rescaling parameter used for normalization (dnorm), which influences the
tension.</li>
</ul>
<p>The program gives a warning when the user wants to interpolate outside
the region given by the <i>input</i> raster map's header data. Zooming into the
area where the points are is suggested in this case.
<p>When a mask is used, the program uses all points in the given region for 
interpolation, including those in the area which is masked out, to ensure 
proper interpolation along the border of the mask. It therefore does not 
mask out the data points; if this is desirable, it must be done outside 
<i>r.resamp.rst</i> before processing.

<h2>EXAMPLE</h2>

Resampling the Spearfish 30m resolution elevation model to 15m:
 
<div class="code"><pre>
# set computation region to original map (30m)
g.region raster=elevation.dem -p

# resample to 15m
r.resamp.rst input=elevation.dem ew_res=15 ns_res=15 elevation=elev15

# set computation region to resulting map
g.region raster=elev15 -p

# verify
r.univar elev15 -g
</pre></div>

<h2>SEE ALSO</h2>

<a href="g.region.html">g.region</a>,
<a href="r.info.html">r.info</a>,
<a href="r.resample.html">r.resample</a>,
<a href="r.mapcalc.html">r.mapcalc</a>,
<a href="r.surf.contour.html">r.surf.contour</a>,
<a href="v.surf.rst.html">v.surf.rst</a>

<p>
Overview: <a href="https://grasswiki.osgeo.org/wiki/Interpolation">Interpolation and Resampling</a> in GRASS GIS

<h2>AUTHORS</h2>

<i>Original version of program (in FORTRAN):</i>
<br>Lubos Mitas, NCSA, University of Illinois at Urbana Champaign, Il
<br>Helena Mitasova, US Army CERL, Champaign, Illinois&nbsp;
<p><i>Modified program (translated to C, adapted for GRASS , segmentation
procedure):</i>
<br>Irina Kosinovsky, US Army CERL.
<br>Dave Gerdes, US Army CERL.

<h2>REFERENCES</h2>

Mitas, L., Mitasova, H., 1999, Spatial Interpolation. In: P.Longley, M.F.
Goodchild, D.J. Maguire, D.W.Rhind (Eds.), Geographical Information Systems:
Principles, Techniques, Management and Applications, Wiley, 481-492.
<p>Mitasova, H. and Mitas, L., 1993. Interpolation by regularized spline
with tension: I. Theory and implementation, Mathematical Geology No.25
p.641-656.
<p>Mitasova, H. and Hofierka, L., 1993. Interpolation by regularized spline
with tension: II. Application to terrain modeling and surface geometry
analysis, Mathematical Geology No.25 p.657-667.
<p>Talmi, A. and Gilat, G., 1977. Method for smooth approximation
of data, Journal of Computational Physics , 23, pp 93-123.
<p>Wahba, G., 1990. Spline models for observational data, CNMS-NSF Regional
Conference series in applied mathematics, 59, SIAM, Philadelphia, Pennsylvania.
<!--
<p>
<i>Last changed: $Date$</i>
-->
